package com.jt.demos;

import redis.clients.jedis.Jedis;

public class SecondKillDemo01{




 static void enque(String msg){
  Jedis jedis=new Jedis("192.168.126.129",6379);

  jedis.lpush("queue",msg);
 }

 static String deque(){
  Jedis jedis=new Jedis("192.168.126.129",6379);
  return jedis.rpop("queue");
 }

 public static void main(String[] args) throws InterruptedException{


  new Thread(){
   public void run(){
    for(int i=1;i<=10;i++){
     enque(String.valueOf(i));
     try{
      Thread.sleep(100);
     }catch(InterruptedException e){
      e.printStackTrace();
     }
    }
   }
  }.start();


  new Thread(){
   public void run(){
  for(;;){
   String msg=deque();
   if(msg==null) continue;
   System.out.print(msg);
  }
   }
  }.start();
 }
}
